## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-

def configure(conf):
    if conf.env['ENABLE_THREADING']:
        conf.env['ENABLE_EMU'] = conf.check(header_name='netpacket/packet.h',
                                            define_name='HAVE_PACKET_H')
        conf.report_optional_feature("EmuNetDevice", "Emulated Net Device",
                                     conf.env['ENABLE_EMU'],
                                     "<netpacket/packet.h> include not detected")
    else:
        conf.report_optional_feature("EmuNetDevice", "Emulated Net Device",
                                     False,
                                     "needs threading support which is not available")

def build(bld):
    module = bld.create_ns3_module('emu', ['node'])
    module.source = [
        ]
    headers = bld.new_task_gen('ns3header')
    headers.module = 'emu'
    headers.source = [
        'emu.h',
        ]

    env = bld.env_of_name('default')
    if env['ENABLE_EMU']:
        module.source.extend([
                'emu-net-device.cc',
                'emu-encode-decode.cc',
                ])
        headers.source.extend([
                'emu-net-device.h',
                ])

        obj = bld.create_suid_program('emu-sock-creator')
        obj.source = [
            'emu-sock-creator.cc',
            'emu-encode-decode.cc',
            ]


